package org.libarae.communication.response;

import org.libarae.communication.XmlParseException;
import org.w3c.dom.Document;

public abstract class Response {
	//Status
	public static final int STATUS_GOOD = 0;
	public static final int STATUS_FAILED_GENERIC = 1;
	public static final int STATUS_FAILED_BAD_KEY = 2;
	
	private int mType; //defined in communication.common.Type
	private int mStatus;
	
	public Response(int type, int status){
		this.mType = type;
		this.mStatus = status;
	}
	
	private String htmlHelperMessage;
	
	/**
	 * Sets a helper message to be set as a cookie by the server interface, used for the HTML client
	 * @param htmlHelperMessage
	 */
	public void setHtmlHelperMessage(String htmlHelperMessage) {
		this.htmlHelperMessage = htmlHelperMessage;
	}
	
	/**
	 * 
	 * @return the helper message to be set as a cookie for an HTML client
	 */
	public String getHtmlHelperMessage() {
		return htmlHelperMessage;
	}
	
	public abstract String createXML() throws XmlParseException;
	public abstract void decodeXML(Document document);
	
	/**
	 * Creates an HTML web page for this Response type. 
	 * The page will display the information request, 
	 * links to make other requests, and the forms 
	 * necessary for the web page to respond with 
	 * other POST requests.
	 *  
	 * @return a HTML representaiton of the page
	 */
	public abstract String createHTML();
	
	public int getType() {
		return mType;
	}

	public void setType(int type) {
		this.mType = type;
	}
	
	/**
	 * @return the mStatus
	 */
	public int getStatus() {
		return mStatus;
	}

	/**
	 * @param mStatus the mStatus to set
	 */
	public void setStatus(int mStatus) {
		this.mStatus = mStatus;
	}
}
